﻿namespace ``Concerning the assertion syntax``

open Gallio.Framework.Assertions
open Gallio.Framework
open System.Linq

[<AutoOpen>]
module TestHelper =
    //captures an assertion failure and outputs it to the testLog.
    //Asserts that only one failure was logged
    let capture (action:unit->unit) =
        let failures = AssertionHelper.Eval(new Gallio.Common.Action(action))
        if failures.Length <> 0 then
            use section = (TestLog.BeginSection("Captured assertion failures"))
            for (failure:AssertionFailure) in failures do
                failure.WriteTo TestLog.Default 
        failures.Single()
    

    //assertion labels
    let label (x:string*string) =
        let lhs, rhs = x
        new AssertionFailure.LabeledValue(lhs, rhs)
    
    //integers
    let zero    = 0
    let one     = 1
    let two     = 2
    
    //dates
    let date str = System.DateTime.Parse str
    let createDate year month day = new System.DateTime (year, month, day)

    //units of measure
    //Distance, metres
    [<Measure>] type m
    //Time, seconds
    [<Measure>] type s

    //Misc. types
    type Person = { Name:string; Age:int; }